function moduleConfig(base,type,text) {
    if(base && Object.keys(base).length > 0){
        if(typeof type == 'string'){
            if(base[type]){
                return text
            }
            return ''
        }else if(Array.isArray(type)){
            let key = base[type[0]];
            if(key){
                if(type.length > 1){
                    for(let i = 1;i <= type.length;i++){
                        key = key[type[i]]
                        if(key){
                            return text
                        }
                        return ''
                    } 
                }else{
                    return text
                }
            }
            return ''
        }else{
            return text
        }
    }
    return ''
}


function getChannel(configs){
    let str = ''
    if(configs.adUserConfig && configs.adUserConfig.streamAppChannel && configs.adUserConfig.streamAppChannel.length > 0){
        configs.adUserConfig.streamAppChannel.forEach(item => {
            str += `<meta-data android:name="DCLOUD_STREAMAPP_CHANNEL" android:value="${configs.packageName}|${configs.appid}|${item}" />
            `
        })

    }
    return str
    // <meta-data android:name="DCLOUD_STREAMAPP_CHANNEL" android:value="包名|应用标识|广告标识|渠道，如io.dcloud.appid|appid|adid|google" />
}

module.exports = function (config) {
  return {
    // 项目名称
    app_name: `<resources>
  <string name="app_name">${config.name}</string>
  ${
    moduleConfig(config.oauth,['facebook'],`<string name="facebook_app_id">${config.oauthUserConfig?.facebook?.facebook_app_id}</string>
<string name="fb_login_protocol_scheme">${config.oauthUserConfig?.facebook?.fb_login_protocol_scheme}</string>`)
    }
</resources>`,
    app_control: `<hbuilder>
<apps>
    <app appid="${config.appid}" appver=""/>
</apps>
</hbuilder>`,
    androidManifest: `<?xml version="1.0" encoding="utf-8"?>
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="${config.packageName}">

    ${config.permission.join('\n')}
    ${
        moduleConfig(config.ad,'ks',`<!--快手广告——开始-->
        <permission
            android:name="${config.packageName}.permission.KW_SDK_BROADCAST"
            android:protectionLevel="signature" />
        <uses-permission android:name="${config.packageName}.permission.KW_SDK_BROADCAST" />    
    <!--快手-—结束-->`)||
    moduleConfig(config.ad,'ks-content',`<!--快手广告——开始-->
        <permission
            android:name="${config.packageName}.permission.KW_SDK_BROADCAST"
            android:protectionLevel="signature" />
        <uses-permission android:name="${config.packageName}.permission.KW_SDK_BROADCAST" />    
    <!--快手-—结束-->`)
    }

    <application
        android:allowBackup="true"
        android:allowClearUserData="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:largeHeap="true"
        tools:replace="android:allowBackup"
        android:supportsRtl="true">
        <activity
            android:name="io.dcloud.PandoraEntry"
            android:configChanges="orientation|keyboardHidden|keyboard|navigation"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:hardwareAccelerated="true"
            android:theme="@style/TranslucentTheme"
            android:screenOrientation="${ config.pageOrientation || 'user'}"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            ${  
                moduleConfig(config.push,null,`<intent-filter>
                <action android:name="android.intent.action.VIEW"/> 
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="io.dcloud.unipush" android:path="/" android:scheme="unipush" />
            </intent-filter>`)
            }
            ${  
                moduleConfig(config.push,['oppo'],`<!--oppo配置开始-->
            <intent-filter>
                <action android:name="android.intent.action.oppopush" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!--oppo配置结束-->`)
            }
        </activity>
        <activity
            android:name="io.dcloud.PandoraEntryActivity"
            android:launchMode="singleTask"
            android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize|uiMode"
            android:hardwareAccelerated="true"
            android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
            android:screenOrientation="${ config.pageOrientation || 'user'}"
            android:theme="@style/DCloudTheme"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme=" " />
            </intent-filter>
        </activity>
        <meta-data android:name="dcloud_appkey" android:value="${config.dcloudAppkey}" />
        
        ${  
            moduleConfig(config.push,['fcm'],`<!--fcm推送-->
        <service android:name="io.dcloud.feature.fcm.FCMVendorService" android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="${config.uniPushUserConfig?.fcm?.channel_id}" />
		<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/push_icon" />`)
        }  
        ${  
            moduleConfig(config.geolocation || config.maps,'baidu',`<!--百度定位-->
        <meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="${config?.geolocation?.baidu?.appkey_android || config?.maps?.baidu?.appkey_android }">
        </meta-data><service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote"></service>`)

        }
        ${  
            moduleConfig(config.geolocation || config.maps,'amap',`<!--高德定位-->
        <meta-data android:name="com.amap.api.v2.apikey" android:value="${config?.geolocation?.amap?.appkey_android || config?.maps?.amap?.appkey_android}">
        </meta-data><service android:name="com.amap.api.location.APSService"></service>`)
        }
        ${  
            moduleConfig(config.push,'mi',` <!--小米厂商配置——开始-->
        <meta-data android:name="MIPUSH_APPID" android:value="${config.uniPushUserConfig?.mi?.appid}" />
        <meta-data android:name="MIPUSH_APPKEY" android:value="${config.uniPushUserConfig?.mi?.appkey}" />
        <!--小米厂商配置——结束-->`)
        }
        ${  
            moduleConfig(config.push,'meizu',` <!--魅族厂商配置——开始-->
        <meta-data android:name="MEIZUPUSH_APPID" android:value="${config.uniPushUserConfig?.meizu?.appid}" />
        <meta-data android:name="MEIZUPUSH_APPKEY" android:value="${config.uniPushUserConfig?.meizu?.appkey}" />
        <!--魅族厂商配置——结束-->`)
        }
        ${
            moduleConfig(config.push,'oppo',` <!--oppo厂商配置——开始-->
        <meta-data android:name="OPPOPUSH_APPKEY" android:value="${config.uniPushUserConfig?.oppo?.appkey}" />
        <meta-data android:name="OPPOPUSH_APPSECRET" android:value="${config.uniPushUserConfig?.oppo?.appsecret}" />
        <!--oppo厂商配置——结束-->`)
        }
        ${
            moduleConfig(config.push,'vivo',` <!--vivo厂商配置——开始-->
        <meta-data android:name="com.vivo.push.app_id" android:value="${config.uniPushUserConfig?.vivo?.appid}" />
        <meta-data android:name="com.vivo.push.api_key" android:value="${config.uniPushUserConfig?.vivo?.appkey}" />
        <!--vivo厂商配置——结束-->`)
        }
        ${
            moduleConfig(config.push,'hms',` <!--华为厂商配置——开始-->
        <meta-data android:name="com.huawei.hms.client.appid" android:value="${config.uniPushUserConfig?.hms?.appid}" />
        <!--华为厂商配置——结束-->`)
        }
 
        ${
            moduleConfig(config.share || config.oauth || config.payment,'weixin',` <!--微信配置——开始-->
        <meta-data android:name="WX_APPID" android:value="${config.commonUserConfig?.weixin?.appid }"></meta-data>
        <meta-data android:name="WX_SECRET" android:value="${config.commonUserConfig?.weixin?.appsecret}"></meta-data>
        <activity
            android:name="${config.packageName}.wxapi.WXEntryActivity"
            android:label="@string/app_name"
            android:exported="true"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:scheme="${config.commonUserConfig?.weixin?.appid}"/>
            </intent-filter>
        </activity>
        <!--微信配置——结束-->`)
        }
        ${
            moduleConfig(config.share || config.oauth,'qq',` <!--qq配置——开始-->
        <meta-data android:value="${config.commonUserConfig?.qq?.appid }" android:name="QQ_APPID"/> 
        <activity android:name="com.tencent.tauth.AuthActivity" android:launchMode="singleTask" android:noHistory="true"> 
        <intent-filter>
        <action android:name="android.intent.action.VIEW"/> 
        <category android:name="android.intent.category.DEFAULT"/> 
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="${config.commonUserConfig?.qq?.appid }"/> 
        </intent-filter> 
        </activity> 
        <activity android:name="com.tencent.connect.common.AssistActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrientation="portrait"/>
        <!--qq配置——结束-->`)
        }
        ${
            moduleConfig(config.share || config.oauth,'sina',` <!--新浪配置——开始-->
        <!-- 官方网站：http://open.weibo.com/ -->
        <meta-data android:name="SINA_APPKEY" android:value="_${config.commonUserConfig?.sina?.appkey }" />
        <meta-data android:name="SINA_SECRET" android:value="${config.commonUserConfig?.sina?.appsecret }" />
        <meta-data android:name="SINA_REDIRECT_URI" android:value="${config.commonUserConfig?.sina?.redirect_uri }" />
        <activity android:name="com.sina.weibo.sdk.web.WeiboSdkWebActivity"
            android:configChanges="keyboardHidden|orientation"
            android:exported="false"
            android:windowSoftInputMode="adjustResize">
        </activity>
        <!--新浪配置——结束-->`)
        }
        ${
        moduleConfig(config.share,'sina',` <!--新浪分享——开始-->
        <activity android:name="com.sina.weibo.sdk.share.WbShareTransActivity"
            android:launchMode="singleTask"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
                <intent-filter>
                    <action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
        </activity>
        <!--新浪分享——结束-->`)
        }
        ${
            moduleConfig(config.maps,'google',` <!--谷歌地图——开始-->
            <meta-data android:name="com.google.android.geo.API_KEY" android:value="${config.maps?.google?.APIKey_android}" tools:replace="android:value" />
            <!--谷歌地图-—结束-->`)
        }
        ${
            moduleConfig(config.payment,['paypal'],`<!--paypal——开始-->
        <activity
        android:name="com.paypal.openid.RedirectUriReceiverActivity"
        android:excludeFromRecents="true"
        android:exported="true"
        android:theme="@style/PYPLAppTheme">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="paypalpay"
                android:scheme="${config.paymentUserConfig?.paypal?.scheme}" />
        </intent-filter>
        </activity>

        <activity
        android:name="com.paypal.pyplcheckout.home.view.activities.PYPLInitiateCheckoutActivity"
        android:exported="true"
        android:theme="@style/AppFullScreenTheme">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="paypalxo"
                android:scheme="${config.paymentUserConfig?.paypal?.scheme}" />
        </intent-filter>
        </activity>

        <meta-data android:name="returnUrl" android:value="${config.paymentUserConfig?.paypal?.scheme}://paypalpay"/>
        <!--paypal-—结束-->`)
        }
        ${
            moduleConfig(config.payment,['stripe'],`<!--stripe支付——开始-->
            <activity
            android:name="io.dcloud.feature.payment.stripe.TransparentActivity"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/TranslucentTheme" />
        <!--stripe支付-—结束-->`)
        }
        ${
            moduleConfig(config.payment,['google'],`<!--google支付——开始-->
        <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
        <!--google支付-—结束-->`)
        }
        ${
            moduleConfig(config.speech,'baidu',`<!--百度语音——开始-->
            <meta-data android:name="com.baidu.speech.APP_ID" android:value="${config.speech?.baidu?.appid}"/>
            <meta-data android:name="com.baidu.speech.API_KEY" android:value="${config.speech?.baidu?.apikey}"/>
            <meta-data android:name="com.baidu.speech.SECRET_KEY" android:value="${config.speech?.baidu?.secretkey}"/>
            <service android:name="com.baidu.speech.VoiceRecognitionService" android:exported="false" />
        <!--百度语音-—结束-->`)
        }

        ${
            moduleConfig(config.statics,'umeng',`<!--友盟统计——开始-->
            <meta-data android:name="UMENG_APPKEY" android:value="${config.statics?.umeng?.appkey_android}" />
            <meta-data android:name="UMENG_CHANNEL" android:value="${config.statics?.umeng?.channelid_android}" />"
        <!--友盟统计-—结束-->`)
        }
        ${
            moduleConfig(config.ad,null,`<!--广告配置——开始-->
            <!--如果不开启开屏广告则不设置此字段或者值设置为false-->
            <meta-data android:name="DCLOUD_AD_SPLASH" android:value="${config.adUserConfig?.splash || false}"/>
            ${getChannel(config) }
        <!--广告配置-—结束-->`)
        }
        ${
            moduleConfig(config.ad,'csj',`<!--穿山甲广告——开始-->
                <provider
                android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
                android:authorities="${config.packageName}.TTFileProvider"
                android:exported="false"
                android:grantUriPermissions="true">
                <meta-data
                    android:name="android.support.FILE_PROVIDER_PATHS"
                    android:resource="@xml/file_paths"
                    tools:replace="android:resource"/>
            </provider>

            <provider
                android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
                android:authorities="${config.packageName}.TTMultiProvider"
                android:exported="false" />
        <!--穿山甲广告-—结束-->`)
        }
      
    </application>
</manifest>`,
    buildGradle:`apply plugin: 'com.android.application'
${  
    moduleConfig(config.push,['hms'],`apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'`)
}
${  
    moduleConfig(config.push,['fcm'],`apply plugin: 'com.google.gms.google-services'`)||
    moduleConfig(config.statics,'google',`apply plugin: 'com.google.gms.google-services'`)
}
android {
    compileSdkVersion 30
    buildToolsVersion '30.0.2'
    defaultConfig {
        applicationId "${config.packageName}"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode ${config.versionCode}
        versionName "${config.versionName}"
        multiDexEnabled true
        ndk {
            abiFilters  '${config.abiFilters.join('\',\'')}'
        }
        manifestPlaceholders = [ 
            "TTT": "TTT",
        ${  
            moduleConfig(config.oauth,['univerify'],`
            "GETUI_APPID": "${config.oauthUserConfig?.univerify?.GETUI_APPID}",
            "GY_APP_ID": "${config.oauthUserConfig?.univerify?.GY_APP_ID}",
            "GT_INSTALL_CHANNEL": "HBuilder",`)
        }
        ${  
            moduleConfig(config.push,null,`
            "GETUI_APPID": "${config.uniPushUserConfig?.unipushappid}",
            "plus.unipush.appid": "${config.uniPushUserConfig?.unipushappid}",
            "plus.unipush.appkey": "${config.uniPushUserConfig?.unipuishappkey}",
            "plus.unipush.appsecret": "${config.uniPushUserConfig?.unipushsecrety}",
            "apk.applicationId": "${config.packageName}",`)
        }
        ${
            moduleConfig(config.push,['mi','appid'],`"MIPUSH_APPID": "${config.uniPushUserConfig?.mi?.appid}",`)
        }
        ${
            moduleConfig(config.push,['mi','appkey'],`"MIPUSH_APPKEY": "${config.uniPushUserConfig?.mi?.appkey}",`)
        }
        ${
            moduleConfig(config.push,['meizu','appid'],`"MEIZUPUSH_APPID": "${config.uniPushUserConfig?.meizu?.appid}",`)
        }
        ${
            moduleConfig(config.push,['meizu','appkey'],`"MEIZUPUSH_APPKEY": "${config.uniPushUserConfig?.meizu?.appkey}",`)
        }
        ${
            moduleConfig(config.push,['oppo','appkey'],`"OPPOPUSH_APPKEY": "${config.uniPushUserConfig?.oppo?.appkey}",`)
        }
        ${
            moduleConfig(config.push,['oppo','appsecret'],`"OPPOPUSH_APPSECRET": "${config.uniPushUserConfig?.oppo?.appsecret}",`)
        }
        ${
            moduleConfig(config.push,['vivo','appid'],`"com.vivo.push.app_id": "${config.uniPushUserConfig?.vivo?.appid}",`)
        }
        ${
            moduleConfig(config.push,['vivo','appkey'],`"com.vivo.push.api_key": "${config.uniPushUserConfig?.vivo?.appkey}",`)
        }
        ${
            moduleConfig(config.push,['hms','appid'],`"com.huawei.hms.client.appid": "${config.uniPushUserConfig?.hms?.appid}",`)
        }
        ]

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    signingConfigs {
        config {
            storeFile file('keys.keystore')
            keyAlias '${config.alias}'
            keyPassword '${config.storepass}'
            storePassword '${config.storepass}'
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.config
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            signingConfig signingConfigs.config
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    aaptOptions {
        additionalParameters '--auto-add-overlay'
        ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    packagingOptions {
        pickFirst 'lib/*/libc++_shared.so'
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.facebook.fresco:fresco:2.5.0'
    implementation "com.facebook.fresco:animated-gif:2.5.0"
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'com.alibaba:fastjson:1.2.83'
    implementation 'androidx.webkit:webkit:1.3.0'
    
    ${
        moduleConfig(config.geolocation || config.maps,'amap',config?.geolocation?.amap?.dependencies)
    }
    ${
        moduleConfig(config.share || config.oauth,'weixin',config?.share?.weixin?.dependencies || config?.oauth?.weixin?.dependencies)
    }
    ${
        moduleConfig(config.payment,'alipay',config?.payment?.alipay?.dependencies)
    }
    ${
        moduleConfig(config.push,['oppo'],`implementation 'com.google.code.gson:gson:2.6.2' 
    implementation 'commons-codec:commons-codec:1.6' 
    implementation 'androidx.annotation:annotation:1.1.0'`)
    }
    ${
        moduleConfig(config.push,['hms'],`implementation 'com.huawei.hms:push:6.5.0.300'`)
    }
    ${
        moduleConfig(config.push,['fcm'],`implementation 'com.google.firebase:firebase-messaging:23.0.0'`)
    }
    ${
        moduleConfig(config.oauth,['google'],`implementation 'com.google.android.gms:play-services-auth:19.2.0'`)
    }
    ${
        moduleConfig(config.maps,['google'],`implementation 'com.google.android.gms:play-services-maps:18.0.1'`)
    }
    ${
        moduleConfig(config.oauth,['facebook'],`implementation 'com.facebook.android:facebook-login:12.0.0'`)
    }
    ${
        moduleConfig(config.facialRecognitionVerify,null,`implementation "androidx.core:core-ktx:1.6.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0"
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.0"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8"
    implementation "com.airbnb.android:lottie:3.4.0"
    implementation "com.squareup.okhttp3:okhttp:3.11.0"
    implementation "com.squareup.okio:okio:1.14.0"
    implementation "com.aliyun.dpa:oss-android-sdk:+"`)
    }
    ${moduleConfig(config.payment,['paypal'],`implementation 'com.paypal.checkout:android-sdk:0.6.2'`)}
    ${moduleConfig(config.payment,['stripe'],`implementation 'com.stripe:stripe-android:18.2.0'`)}
    ${moduleConfig(config.payment,['google'],`implementation 'com.google.android.gms:play-services-wallet:18.1.3'`)}

    ${
        moduleConfig(config.statics,'umeng',config?.statics?.umeng?.dependencies)
    }
    ${
        moduleConfig(config.statics,'google',`implementation 'com.google.firebase:firebase-analytics:20.0.0'`)
    }
    ${
        moduleConfig(config.ad,'hw',`implementation 'com.huawei.hms:ads-lite:13.4.56.302'
    implementation 'com.huawei.hms:ads-omsdk:1.3.35'`)
    }

    ${
        config.userPlugins && `implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
        implementation 'androidx.core:core:1.1.0'
        implementation "androidx.fragment:fragment:1.1.0"
        api 'com.google.code.gson:gson:2.7'`
    }
    
}`
    ,
    dcloud_properties:`<properties>
	<features>
        ${moduleConfig(config.ad,null,`<!--ad-->
        <feature name="Ad" value="io.dcloud.feature.ad.AdFlowFeatureImpl">`)}
            ${
                moduleConfig(config.ad,'csj',` <!--穿山甲-->
                <module name="csj" value="io.dcloud.feature.ad.csj.ADCsjModule"/>`)
            }
            ${
                moduleConfig(config.ad,'csj',` <!--腾讯优量汇-->
                <module name="gdt" value="io.dcloud.feature.ad.gdt.ADGdtModule"/>`)
            }
            ${
                moduleConfig(config.ad,'ks',` <!--快手广告联盟-->
                <module name="ks" value="io.dcloud.feature.ad.ks.ADKsModule"/>`)||
                moduleConfig(config.ad,'ks-content',` <!--快手内容联盟-->
                <module name="ks" value="io.dcloud.feature.ad.ks.ADKsModule"/>`)
            }
            ${
                moduleConfig(config.ad,'sigmob',` <!--sigmob-->
                <module name="sgm" value="io.dcloud.feature.ad.sigmob.ADSMModule"/>`)
            }
            ${
                moduleConfig(config.ad,'bd',` <!--百度广告-->
                <module name="bd" value="io.dcloud.feature.ad.bd.ADBDModule" />`)
            }
            ${
                moduleConfig(config.ad,'hw',` <!--华为广告-->
                <module name="hw" value="io.dcloud.feature.ad.hw.AdHwModule" />`)
            }
            ${
                moduleConfig(config.ad,'gm',` <!--穿山甲GroMore-->
                <module name="gm" value="io.dcloud.feature.ad.gm.AdGMModule"/>`)
            }
        ${moduleConfig(config.ad,null,`</feature>`)}


		<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
        ${moduleConfig(config.speech,null,`<!--语音-->
        <feature name="Speech" value="io.dcloud.feature.speech.SpeechFeatureImpl">`)}
            ${
                moduleConfig(config.speech,'baidu',` <!--百度语音-->
            <module name="baidu" value="io.dcloud.feature.speech.BaiduSpeechEngine"/>`)
            }
        ${moduleConfig(config.speech,null,`</feature>`)}
        ${moduleConfig(config.statics,null,`<!--统计-->
        <feature name="Statistic" value="io.dcloud.feature.statistics.StatisticsFeatureImpl">`)}
            ${
                moduleConfig(config.statics,'umeng',` <!--友盟统计-->
                <module name="Statistic-Umeng" value="io.dcloud.feature.statistics.umeng.UmengStatistics" />`)
            }
            ${
                moduleConfig(config.statics,'google',` <!--google统计-->
                <module name="Statistic-Google" value="io.dcloud.feature.statistics.google.GoogleStatistics" />`)
            }
        ${moduleConfig(config.statics,null,`</feature>`)}
        ${
            moduleConfig(config.maps,'baidu',` <!--百度地图-->
        <feature name="Maps" value="io.dcloud.js.map.JsMapPluginImpl"></feature>`)
        }
        ${
            moduleConfig(config.maps,'amap',` <!--高德地图-->
        <feature name="Maps" value="io.dcloud.js.map.amap.JsMapPluginImpl"/>`)
        }
        ${
            moduleConfig(config.oauth,null,` <!--登陆授权-->
        <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl">`)
            
        }
        ${moduleConfig(config.oauth,['univerify'],`<!--一键登陆-->
        <module name="OAuth-IGETui" value="io.dcloud.feature.igetui.GeTuiOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,['weixin'],`<!--微信登陆-->
        <module name="OAuth-Weixin" value="io.dcloud.feature.oauth.weixin.WeiXinOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,['qq'],`<!--qq登陆-->
        <module name="OAuth-QQ" value="io.dcloud.feature.oauth.qq.QQOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,['sina'],`<!--新浪登陆-->
        <module name="OAuth-Sina" value="io.dcloud.feature.oauth.sina.SinaOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,['google'],`<!--谷歌登陆-->
        <module name="OAuth-Google" value="io.dcloud.feature.google.GoogleOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,['facebook'],`<!--facebook登陆-->
        <module name="OAuth-Facebook" value="io.dcloud.feature.facebook.FacebookOAuthService"/>`)
        }
        ${moduleConfig(config.oauth,null,`</feature>`)}
        ${moduleConfig(config.payment,null,`<!--支付-->
        <feature name="Payment" value="io.dcloud.feature.payment.PaymentFeatureImpl">`)}
            ${moduleConfig(config.payment,['alipay'],`<!--支付宝支付-->
            <module name="AliPay" value="io.dcloud.feature.payment.alipay.AliPay"/>`)}
            ${moduleConfig(config.payment,['weixin'],`<!--微信支付-->
            <module name="Payment-Weixin" value="io.dcloud.feature.payment.weixin.WeiXinPay"/>`)}
            ${moduleConfig(config.payment,['paypal'],`<!--paypal支付-->
            <module name="Payment-Paypal" value="io.dcloud.feature.payment.paypal.PaypalPay" />`)}
            ${moduleConfig(config.payment,['stripe'],`<!--stripe支付-->
            <module name="Payment-Stripe" value="io.dcloud.feature.payment.stripe.StripePay"/>`)}
            ${moduleConfig(config.payment,['google'],`<!--google支付-->
            <module name="Payment-Google" value="io.dcloud.feature.payment.google.GooglePay"/>`)}
        ${moduleConfig(config.payment,null,`</feature>`)}
		<feature name="Contacts" value="io.dcloud.feature.contacts.ContactsFeatureImpl"/>
		<feature name="Messaging" value="io.dcloud.adapter.messaging.MessagingPluginImpl"/>
		<feature name="Camera" value="io.dcloud.js.camera.CameraFeatureImpl"/>
		<feature name="Console" value="io.dcloud.feature.pdr.LoggerFeatureImpl"/>
		<feature name="Device" value="io.dcloud.feature.device.DeviceFeatureImpl"/>
		<feature name="File" value="io.dcloud.js.file.FileFeatureImpl"/>
		<feature name="Proximity" value="io.dcloud.feature.sensor.ProximityFeatureImpl"/>
		<feature name="Storage" value="io.dcloud.feature.pdr.NStorageFeatureImpl"/>
		<feature name="Cache" value="io.dcloud.feature.pdr.CoreCacheFeatureImpl"/>
		<feature name="Invocation" value="io.dcloud.invocation.Invocation"/>
		<feature name="Navigator" value="io.dcloud.feature.ui.navigator.NavigatorUIFeatureImpl"/>
		<feature name="NativeUI" value="io.dcloud.feature.ui.nativeui.NativeUIFeatureImpl"/>
		<feature name="UI" value="io.dcloud.feature.ui.UIFeatureImpl">
			<module name="Navigator" value="io.dcloud.feature.ui.NavView"/>
		</feature>
		<feature name="Gallery" value="io.dcloud.js.gallery.GalleryFeatureImpl"/>
		<feature name="Downloader" value="io.dcloud.net.DownloaderFeatureImpl"/>
		<feature name="Uploader" value="io.dcloud.net.UploadFeature"/>
		<feature name="Zip" value="io.dcloud.feature.pdr.ZipFeature"/>
		<feature name="Audio" value="io.dcloud.feature.audio.AudioFeatureImpl"/>
		<feature name="Runtime" value="io.dcloud.feature.pdr.RuntimeFeatureImpl"/>
        <feature name="VideoPlayer" value="io.dcloud.media.MediaFeatureImpl"/>
        <feature name="LivePusher" value="io.dcloud.media.live.LiveMediaFeatureImpl"/>
		<feature name="XMLHttpRequest" value="io.dcloud.net.XMLHttpRequestFeature"/>
		<feature name="Statistic" value="io.dcloud.feature.statistics.StatisticsFeatureImpl"/>
		<feature name="Accelerometer" value="io.dcloud.feature.sensor.AccelerometerFeatureImpl"/>
		<feature name="Orientation" value="io.dcloud.feature.sensor.OrientationFeatureImpl"/>
		<feature name="NativeObj" value="io.dcloud.feature.nativeObj.FeatureImpl"/>		
		<feature name="Geolocation" value="io.dcloud.js.geolocation.GeolocationFeatureImpl"/>
		<feature name="Stream" value="io.dcloud.appstream.js.StreamAppFeatureImpl"/>
        <feature name="plugintest" value="com.example.H5PlusPlugin.PGPlugintest"/>
        ${  
            moduleConfig(config.push,null,`<!--uniPush-->
        <feature name="Push" value="io.dcloud.feature.aps.APSFeatureImpl">
			<module name="unipush" value="io.dcloud.feature.unipush.GTPushService"/>`)
        }
        ${moduleConfig(config.push,['fcm'],`<!--fcm推送-->
            <module name="fcm" value="io.dcloud.feature.fcm.FCMPushService" />`)
        }
        ${
            moduleConfig(config.push,null,`</feature>`)
        }
        ${  
            moduleConfig(config.share,null,`<!--分享功能-->
        <feature name="Share" value="io.dcloud.share.ShareFeatureImpl">`)
        }
        ${moduleConfig(config.share,['weixin'],`<!--微信分享-->
        <module name="Weixin" value="io.dcloud.share.mm.WeiXinApiManager"/>`)
        }
        ${moduleConfig(config.share,['qq'],`<!--qq分享-->
        <module name="QQ" value="io.dcloud.share.qq.QQApiManager"/>`)
        }
        ${moduleConfig(config.share,['sina'],`<!--新浪分享-->
        <module name="Sina" value="io.dcloud.share.sina.SinaWeiboApiManager"/>`)
        }
        ${
            moduleConfig(config.share,null,`</feature>`)
        }
	</features>

	<services>
		<service name="push" value="io.dcloud.feature.aps.APSFeatureImpl"/>
		<service name="Statistic" value="io.dcloud.feature.statistics.StatisticsBootImpl"/>
		<service name="Downloader" value="io.dcloud.net.DownloaderBootImpl"/>
        ${
            moduleConfig(config.maps,'baidu',` <!--百度地图-->
        <service name="Maps" value="io.dcloud.js.map.MapInitImpl"/>`)
        }
        ${
            moduleConfig(config.statics,'umeng',` <!--友盟统计-->
            <service name="Statistic-Umeng" value="io.dcloud.feature.statistics.umeng.StatisticsBootImpl"/>`)
        }
	</services>
</properties>`,
    projectGradle:`// Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            maven {url 'https://maven.aliyun.com/repository/google'}
            maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
            maven {url 'https://maven.aliyun.com/repository/public'}

            ${  
                moduleConfig(config.push,['hms'],`// 配置HMS Core SDK的Maven仓地址。华为推送
            maven {url 'https://developer.huawei.com/repo/'}`)||
            moduleConfig(config.ad,'hw',`// 配置HMS Core SDK的Maven仓地址。华为广告
            maven {url 'https://developer.huawei.com/repo/'}`)

            }
            ${  
                moduleConfig(config.payment,['paypal'],`// 配置paypal SDK的Maven仓地址。paypal支付
            maven {
                url "${config.paymentUserConfig?.paypal?.url}"
                credentials {
                    username "${config.paymentUserConfig?.paypal?.username}"
                    password "${config.paymentUserConfig?.paypal?.password}"
                }
            }`)
            }
            ${  
                moduleConfig(config.oauth || config.statics,['google'],`google()`)
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.1'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
            ${  
                moduleConfig(config.push,['hms'],`// 增加agcp配置 华为推送
            classpath 'com.huawei.agconnect:agcp:1.6.0.300'`)||
            moduleConfig(config.ad,'hw',`// 增加agcp配置 华为广告
            classpath 'com.huawei.agconnect:agcp:1.6.0.300'`)
            }
            ${  
                moduleConfig(config.push,['fcm'],`// 谷歌推送
            classpath 'com.google.gms:google-services:4.3.10'`) || 
                moduleConfig(config.oauth || config.statics,['google'],`// 谷歌授权
            classpath 'com.google.gms:google-services:4.3.10'`)
            }
           
        }
    }
    
    allprojects {
        repositories {
            maven {url 'https://maven.aliyun.com/repository/google'}
            maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
            maven {url 'https://maven.aliyun.com/repository/public'}
            ${  
                moduleConfig(config.push,['hms'],`// 配置HMS Core SDK的Maven仓地址。华为推送
            maven {url 'https://developer.huawei.com/repo/'}`)||
            moduleConfig(config.ad,'hw',`// 配置HMS Core SDK的Maven仓地址。华为广告
            maven {url 'https://developer.huawei.com/repo/'}`)

            }
            ${  
                moduleConfig(config.statics,['google'],`google()`)
            }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    `,
    
  };
};
